package utils;

/**
 * Created by zhangliangxue on 2017/11/29.
 */
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class JsonStringConstant {
	
	public static final String CODE = "code";	// json返回code
	
	public static final String DATA = "data";	// json返回成功返回数据字段
	
	public static final String MSG = "msg";	// json返回信息字段
	
	public static final String List = "list";	// json返回信息字段
	
	//接口返回代码
	public static final String CODE_SUCESS = "1000";//成功
	public static final String CODE_FAILD = "4000";//失败
	public static final String CODE_EXCEPTION = "5000";//异常
	
	/**
	* @Title: 返回多条数据 
	* @Description: 返回成功
	* @param @param successMessge
	* @param @param data
	* @param @return    设定文件 
	* @return JSONObject    返回类型 
	* @throws
	 */
	public static JSONObject getSuccessMessage(Object data,String message){
	    JSONObject successJo = new JSONObject();
	    JSONObject listJo = new JSONObject();
	    listJo.put(List, data);
	    successJo.put(CODE, CODE_SUCESS);
	    successJo.put(MSG, message);
	    successJo.put(DATA, listJo);
	    return successJo;
	}
	
	/**
	* @Title: 返回但条数据 
	* @Description: 返回成功
	* @param @param successMessge
	* @param @param data
	* @param @return    设定文件 
	* @return JSONObject    返回类型 
	* @throws
	 */
	public static JSONObject getSuccessInfoMessage(Object data,String message){
	    JSONObject successJo = new JSONObject();
	    successJo.put(CODE, CODE_SUCESS);
	    successJo.put(MSG, message);
	    successJo.put(DATA, data);
	    return successJo;
	}
	
	/**
	* @Title: getSuccessMessage 
	* @Description: 返回成功
	* @param @param successMessge
	* @param @param data
	* @param @return    设定文件 
	* @return JSONObject    返回类型 
	* @throws
	 */
	public static JSONObject getSuccessPageMessage(Object data,String message){
	    JSONObject successJo = new JSONObject();
	    
	    successJo.put(CODE, CODE_SUCESS);
	    successJo.put(MSG, message);
	    successJo.put(DATA, data);
	    return successJo;
	}
	
	/**
	* @Title: getNoDataSuccessMessage 
	* @Description: 返回没有列表数据的结果消息
	* @param @param msg
	* @param @return    设定文件 
	* @return JSONObject    返回类型 
	* @throws
	 */
	public static JSONObject getNoDataSuccessMessage(String msg){
	    JSONObject successJo = new JSONObject();
	    successJo.put(CODE, CODE_SUCESS);
	    successJo.put(MSG, msg);
        return successJo;
	}
	
	/**
	* @Title: getFalseMessage 
	* @Description: 返回失败消息
	* @param @param data
	* @param @return    设定文件 
	* @return JSONObject    返回类型 
	* @throws
	 */
	public static JSONObject getFalseMessage(String msg ){
	    JSONObject falseJo = new JSONObject();
	    falseJo.put(CODE, CODE_FAILD);
	    falseJo.put(MSG, msg);
        return falseJo;
	}
	
}

